

dfly.TerminalTooltip = function() {
   
   this.render();
   
   this.initEvents();
};


dfly.TerminalTooltip.prototype = {
  
  render: function() {
     this.el = inputEx.cn('div', {className: 'dfly-Tooltip'}, {display: 'none'});
     document.body.appendChild(this.el);
  },
  
  initEvents: function() {
     
  },
  
  mouseOverTerminal: function(term) {
       
     this.terminal = term;
     if(this.timer) {
        clearTimeout(this.timer);
     }
     var that = this;
     this.timer = setTimeout(function() { that.displayTooltip(); },500);
  },
   
  
  mouseOutTerminal: function(term) {
       
     if(this.timer) {
      clearTimeout(this.timer);
      this.timer = null;
     }
     
     var that = this;
     this.timer = setTimeout(function() { that.hideTooltip(); },1000);
    
  },
  
  hideTooltip: function() {
      this.el.style.display = "none";
  },
  
  displayTooltip: function() {
     
     var pos = this.terminal.getXY();
     this.el.style.left = pos[0]+"px";
     this.el.style.top = pos[1]+"px";
     
     var outputName = this.terminal.dflyName.substr(7);
     
     this.el.innerHTML = ""; //"Output: <b>"+outputName+"</b><br /><br />"+this.terminal.container.getOutputValue(this.terminal.dflyName);
     
     var data = this.terminal.container.getOutputValue(this.terminal.dflyName);
     this.el.appendChild( jsDataView.generateViewer(data) );
     
     this.el.style.display = "";
  }
  
};

